package samplejquery

import sweet.mvc.api._

class SampleJquerySweetConfig extends SweetConfig {
  loadSysProps("sample-jquery.config", "classpath:/config.properties")
  
  addLayouts("main"->"/view/layout/main.ftl")
    
  def setupConfig {  
    // toolbox.auto.update.begin << DO NOT REMOVE IF YOU WANT Toolbox to auto- generate files
    addControllers("/jquery" -> new JQueryController)
    addControllers("/main" -> new MainController)
    // toolbox.auto.update.end
    
    //Get appVersion for this webapp and save it.
    val appVersion = getAppVersion(servletContextRealPath)
    logger.debug("Setting appVersion to " + appVersion)
    addProps("appVersion" -> appVersion)
    servletContext.setAttribute("appVersion", appVersion)
  }
    
  /** Get user application version string. */
  def getAppVersion(ctxPath: String) = {
    val attr = sweet.helper.ManifestHelper.manifestAttributes(ctxPath)
    //logger.debug("Manifest as props " + (Map() ++ attr).toString)
    attr.getOrElse("Implementation-Name", "sample-jquery-development.latest")
  }
}

